


var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */

/*
 * These are the functions you'll usually want to call
 * They take string arguments and return either hex or base-64 encoded strings
 */
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }

/*
 * Perform a simple self-test to see if the VM is working
 */

/*
 * Calculate the MD5 of an array of little-endian words, and a bit length
 */
function core_md5(x, len)
{
    /* append padding */
    x[len >> 5] |= 0x80 << ((len) % 32);
    x[(((len + 64) >>> 9) << 4) + 14] = len;

    var a =  1732584193;
    var b = -271733879;
    var c = -1732584194;
    var d =  271733878;

    for(var i = 0; i < x.length; i += 16)
    {
        var olda = a;
        var oldb = b;
        var oldc = c;
        var oldd = d;

        a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
        d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
        c = md5_ff(c, d, a, b, x[i+ 2], 17,  606105819);
        b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
        a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
        d = md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);
        c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
        b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
        a = md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
        d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
        c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
        b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
        a = md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);
        d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
        c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
        b = md5_ff(b, c, d, a, x[i+15], 22,  1236535329);

        a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
        d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
        c = md5_gg(c, d, a, b, x[i+11], 14,  643717713);
        b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
        a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
        d = md5_gg(d, a, b, c, x[i+10], 9 ,  38016083);
        c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
        b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
        a = md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
        d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
        c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
        b = md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);
        a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
        d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
        c = md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);
        b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);

        a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
        d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
        c = md5_hh(c, d, a, b, x[i+11], 16,  1839030562);
        b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
        a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
        d = md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);
        c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
        b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
        a = md5_hh(a, b, c, d, x[i+13], 4 ,  681279174);
        d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
        c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
        b = md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);
        a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
        d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
        c = md5_hh(c, d, a, b, x[i+15], 16,  530742520);
        b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);

        a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
        d = md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);
        c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
        b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
        a = md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);
        d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
        c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
        b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
        a = md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
        d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
        c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
        b = md5_ii(b, c, d, a, x[i+13], 21,  1309151649);
        a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
        d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
        c = md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);
        b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);

        a = safe_add(a, olda);
        b = safe_add(b, oldb);
        c = safe_add(c, oldc);
        d = safe_add(d, oldd);
    }
    return Array(a, b, c, d);

}

/*
 * These functions implement the four basic operations the algorithm uses.
 */
function md5_cmn(q, a, b, x, s, t)
{
    return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
    return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
    return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
    return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
    return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}

/*
 * Calculate the HMAC-MD5, of a key and some data
 */
function core_hmac_md5(key, data)
{
    var bkey = str2binl(key);
    if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);

    var ipad = Array(16), opad = Array(16);
    for(var i = 0; i < 16; i++)
    {
        ipad[i] = bkey[i] ^ 0x36363636;
        opad[i] = bkey[i] ^ 0x5C5C5C5C;
    }

    var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
    return core_md5(opad.concat(hash), 512 + 128);
}

/*
 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
 * to work around bugs in some JS interpreters.
 */
function safe_add(x, y)
{
    var lsw = (x & 0xFFFF) + (y & 0xFFFF);
    var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
    return (msw << 16) | (lsw & 0xFFFF);
}

/*
 * Bitwise rotate a 32-bit number to the left.
 */
function bit_rol(num, cnt)
{
    return (num << cnt) | (num >>> (32 - cnt));
}

/*
 * Convert a string to an array of little-endian words
 * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
 */
function str2binl(str)
{
    var bin = Array();
    var mask = (1 << chrsz) - 1;
    for(var i = 0; i < str.length * chrsz; i += chrsz)
        bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
    return bin;
}

/*
 * Convert an array of little-endian words to a string
 */
function binl2str(bin)
{
    var str = "";
    var mask = (1 << chrsz) - 1;
    for(var i = 0; i < bin.length * 32; i += chrsz)
        str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
    return str;
}

/*
 * Convert an array of little-endian words to a hex string.
 */
function binl2hex(binarray)
{
    var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
    var str = "";
    for(var i = 0; i < binarray.length * 4; i++)
    {
        str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
            hex_tab.charAt((binarray[i>>2] >> ((i%4)*8  )) & 0xF);
    }
    return str;
}

/*
 * Convert an array of little-endian words to a base-64 string
 */
function binl2b64(binarray)
{
    var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    var str = "";
    for(var i = 0; i < binarray.length * 4; i += 3)
    {
        var triplet = (((binarray[i   >> 2] >> 8 * ( i   %4)) & 0xFF) << 16)
            | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
            |  ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
        for(var j = 0; j < 4; j++)
        {
            if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
            else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
        }
    }
    return str;
}





    let loginModeHtml='<div class="loginMode" id="loginMode">\n' +
        '    <div class="loginModeInner">\n' +
        '        <p class="top">Hi,您需要登录后才能继续操作哦！</p>\n' +
        '        <div class="loginBox" style="">\n' +
        '            <div class="loginTab">\n' +
        '                <span id="loginModePuLogin" class="clickSpan">密码登录</span>\n' +
        '                <span id="loginModeCodeLogin">验证码登录</span>\n' +
        '            </div>\n' +
        '            <div class="puLoginBox" >\n' +
        '                <input placeholder="请输入手机号码" type="number" id="loginModePhone">\n' +
        '                <input placeholder="请输入登录密码" type="password" id="loginModePass">\n' +
        '                <button id="puloginMode">登录</button>\n' +
        '                <div class="inbox">\n' +
        '                    <p id="ModeRegister">注册</p>\n' +
        '                    <p id="ModeForget">忘记密码？</p>\n' +
        '                </div>\n' +
        '\n' +
        '            </div>\n' +
        '\n' +
        '            <div class="part1" style="display: none">\n' +
        '                <div class="phoneBox">\n' +
        '                    <input type="number" placeholder="请输入手机号码" id="codeModePhone">\n' +
        '                </div>\n' +
        '                <div class="codeBox">\n' +
        '                    <input type="number" placeholder="请输入验证码" id="codeMode">\n' +
        '                    <div class="getCode">获取验证码</div>\n' +
        '                    <div class="wangyiCode" style="display: none"></div>\n' +
        '\n' +
        '                </div>\n' +
        '\n' +
        '                <button class="next" id="codeModeEnt">登录</button>\n' +
        '            </div>\n' +
        '\n' +
        '            <span class="xieyi"> 登录即表示同意<a href="">《借贷家服务协议》</a></span>\n' +
        '\n' +
        '        </div>\n' +
        '        <img src="publicImg/icon@2x.png" id="loginModeClose" class="loginModeClose">\n' +
        '    </div>\n' +
        '</div>\n';



    //切换到普通登录
    $('#loginModePuLogin').click(function () {
        let this_=$(this);
        this_.addClass('clickSpan');
        $('#loginModeCodeLogin').removeClass('clickSpan');
        $('.puLoginBox').show();
        $('.part1').hide();
    });


    //切换到验证码登录
    $('#loginModeCodeLogin').click(function () {

        getSettingPicToken();

        let this_=$(this);
        this_.addClass('clickSpan');
        $('#loginModePuLogin').removeClass('clickSpan');
        $('.puLoginBox').hide();
        $('.part1').show();

        getLoginwangyiCode();
    });

    //隐藏登录
    $('#loginModeClose').click(function () {
        $('#loginMode').hide();
    });

    //
    // function addloginMode(){
    //
    //     $('body').find('#loginMode').remove();
    //
    //     $('body').append(loginModeHtml);
    //
    //
    // }
    //

    //密码登录
    //密码登录
    //密码登录
    //密码登录
    //密码登录


    $('#loginModePass').focus(function () {
        let a = $("#loginModePhone").val();

        if(isNull(a)){
            defaultHint("请输入手机号码")
        }else{
            if(!verifyTel(a)){
                defaultHint('请输入正确的手机号码')
            }
        }

    });


    $('#puloginMode').click(function () {
        var a = $("#loginModePhone").val(),
            b = $('#loginModePass').val(),
            typone = verifyTel(a),
            typtwo = checkPass(b);


        if(isNull(a)){
            defaultHint("请输入手机号码");
            return
        }

        if(isNull(b)){
            defaultHint("请输入密码");
            return
        }
        if(!typone){
            defaultHint("手机号码错误");
            return
        }
        if(!typtwo){
            defaultHint("账号或者密码有误");
            return
        }


        b = hex_md5(b);

        var code='';
        //定位使用用户修改的定位；

        if(notNull(sessionStorage.getItem('userChooseLocationCode'))){
            code = sessionStorage.getItem('userChooseLocationCode');

        }else {
            code = sessionStorage.getItem('autoLocationCode');

        }

        myAjaxFunc({
            url: geturluser + "normalLogin",
            type: 'post',
            dataType: 'json',
            data: {username: a, password: b, currentCityCode: code, platform: 'pc/'+getPlatform()},
            mySuccess: function (data) {
                if (data.success) {

                    localStorage.setItem('pctoken', Base64.encode(data.data.token));

                    setUserInfo(data.data.user);


                    let time = new Date();        //获取当前日(1-31)

                    localStorage.setItem('time', time.getDate());

                    alert('登录成功');

                } else {
                    if (notNull(data.msg)) {
                        defaultHint(data.msg);
                    } else {
                        defaultHint('密码错误');


                    }

                }
            }

        })

    });


    //验证码登录
    //验证码登录
    //验证码登录
    //验证码登录
    //验证码登录

    /*动态验证码登录发送验证码60S*/



    var getPicToken = '';

    var getLoginCode=$("#getLoginCodeMode");

    var flagloginwangyiCode=false;




    //智能无感验证
    function getLoginwangyiCode(){

        let picTokenAppId_=sessionStorage.getItem('picTokenAppId');


        if (notNull( picTokenAppId_)) {

            var serviceProvider =  picTokenAppId_.split(',');
            var service = serviceProvider[0];
            var appid_capthaid = serviceProvider[1];

            /*网易无感*/
            if (service == 'wangyi') {


                initNECaptcha({
                    captchaId: appid_capthaid,
                    element: '#wangyiCodeMode',
                    mode: 'float',
                    width: 320,
                    onReady:function (instance) {
                        // 初始化成功
                        $('.yidun_intelli-text').text('点击获取验证码').css({'line-height':"46px",'color':'#ff6f6e'});
                        $('.yidun_intelli-control').css({
                            height:'48px',
                        });
                        flagloginwangyiCode=true;
                    },
                    onVerify: function (err, data) {

                        if (!err) {
                            getPicToken = data.validate;
                            getpicTokenMessageCode( getPicToken, service);

                            flagloginwangyiCode=false;

                        }
                    }
                },  function onerror(err) {
                    console.log(err)
                    // 验证码初始化失败处理逻辑，例如：提示用户点击按钮重新初始化
                });


            }

        }
        else {
            getLoginCode.show().removeClass('getCodeHui');
            $('#wangyiCode').hide();

        }

    }



    var loginTimeList;
    //倒计时
    function Countdown() {
        getLoginCode.show();
        $('#wangyiCodeMode').hide();

        clearInterval(loginTimeList);
        getLoginCode.addClass('getCodeHui');

        var i = 60;
        loginTimeList = setInterval(function () {
            i--;
            getLoginCode.text("" + i + "S后重发");
            if (i < 0) {
                clearInterval(loginTimeList);
                getLoginwangyiCode();
                getLoginCode.text("获取验证码");
                getLoginCode.removeClass('getCodeHui');

                getLoginCode.hide();

                $('#wangyiCodeMode').show();


            }
        }, 1000);

    }

    //获取验证码

    function getpicTokenMessageCode( getPicToken, service) {


        let telNumber = $("#codeModePhone").val();

        if(verifyTel(telNumber)) {

            myAjaxFunc({
                url: geturluser + "getIdentifyCode",
                type: "post",
                dataType: 'json',
                data: {phone: telNumber, picToken: getPicToken, serviceProvider: service},
                mySuccess: function (data) {
                    if (data.success) {

                        $('#codeMode').focus();
                        if (data.msg == null) {
                            defaultHint('发送成功，请注意短信消息')
                        } else {
                            defaultHint(data.msg)
                        }

                    } else {
                        if (data.msg == null) {
                            defaultHint('发送失败')
                        } else {
                            defaultHint(data.msg)

                        }
                    }

                    //开始倒计时
                    Countdown();
                }
            });
        }else {
            defaultHint('请输入正确的手机号码')
        }
    }


    //手机号码验证 ——通过执行无感智能验证
    $('#codeModePhone').bind('input propertychange', function () {
        let telNumber = $("#codeModePhone").val();
        if (telNumber.length >= 11) {
            if (verifyTel(telNumber)) {


                if(!flagloginwangyiCode){
                    getLoginwangyiCode()
                }

                getLoginCode.hide();

                $('#wangyiCodeMode').show();


            } else {

                defaultHint('请输入正确的手机号码');

                getLoginCode.show();
                $('#wangyiCodeMode').hide();
                clearInterval(loginTimeList);
                getLoginCode.text("获取验证码");
                getLoginCode.removeClass('getCodeHui');

            }

        }else {
            getLoginCode.show();
            $('#wangyiCodeMode').hide();
            clearInterval(loginTimeList);

            getLoginCode.text("获取验证码");
            getLoginCode.removeClass('getCodeHui');


        }

    });

    //失焦验证手机号码
    getLoginCode.click(function () {
        var telNumber = $("#codeModePhone").val(), typ = verifyTel(telNumber);
        if (typ) {
            getLoginwangyiCode()
        } else {

            defaultHint('请输入正确的手机号码')

        }
    });

    $('#codeModeEnt').click(function () {
        var telNumber = $("#codeModePhone").val(),
            checkCode = $("#codeMode").val(),
            typone = verifyTel(telNumber);

        if(isNull(telNumber)){
            defaultHint("请输入手机号码");
            return
        }

        if(isNull(checkCode)){
            defaultHint("请输入验证码");
            return
        }

        if(!typone){
            defaultHint("手机号码错误");
            return
        }

        var code='';
        //定位使用用户修改的定位；

        if(notNull(sessionStorage.getItem('userChooseLocationCode'))){
            code = sessionStorage.getItem('userChooseLocationCode');

        }else {
            code = sessionStorage.getItem('autoLocationCode');

        }

        myAjaxFunc({
            url: geturluser + "phoneLogin",
            type: "post",
            dataType: 'json',
            data: {phone: telNumber, identifyCode: checkCode, currentCityCode: code, platform:'pc/'+getPlatform()},
            mySuccess: function (data) {
                if (data.success) {
                    localStorage.setItem('pctoken', Base64.encode(data.data.token));

                    setUserInfo(data.data.user);
                    var time = new Date();        //获取当前日(1-31)
                    localStorage.setItem('time', time.getDate());

                    alert('登录成功');

                } else {
                    if (data.msg == null) {
                        defaultHint('验证码失效');
                    } else {
                        defaultHint( data.msg);

                    }
                }
            }
        });



    });






//忘记密码
//忘记密码
//忘记密码
//忘记密码
//忘记密码
$('#ModeForget').click(function () {

    sessionStorage.setItem('forgitPW',window.location.href);

    window.location.href='login.html?from=forgit'

});



//注册
//注册
//注册
//注册
//注册


$('#ModeRegister').click(function () {

    sessionStorage.setItem('registerPW',window.location.href);

    window.location.href='login.html?from=register'

});


//退出

$('#TopLoginOut').click(function () {

    myAjaxFunc({
        url:geturluser+"logout",
        type:'post',
        mySuccess:function(){
            sessionStorage.clear();
            localStorage.clear();
            defaultHint('退出成功');
            window.location.href='index.html'
        }
    })
});



$(document).ready(function () {

    //    显示隐藏管理员权限

    // $('.authorInfo').hover(function () {
    //     var this_=$(this);
    //
    //     this_.find('.adminDelAll,.adminDelThis').show();
    //
    // },function () {
    //     var this_=$(this);
    //
    //     this_.find('.adminDelAll,.adminDelThis').hide();
    //
    // });

    //头部信息
    if(islogin()){

        $('#nav_loginCondition_login').hide();
        $('#nav_loginCondition_register').hide();

        $('#nav_usercenter').show();
        $('#nav_suggestion').show();
        $('#TopLoginOut').show();



        let userInfo=getUserInfo();
        console.log(userInfo);



    }else {
        $('#top_loginCondition_login').show();
        $('#top_loginCondition_register').show();



        $('#nav_usercenter').hide();
        $('#nav_suggestion').hide();
        $('#TopLoginOut').hide();



    }


    $('#top_loginCondition_info').hover(function () {
        $('.userInfoList').show();
    },function () {
        // $('.userInfoList').hide();

    });

    $('.userInfoList').hover(function () {
        // $('.userInfoList').show();
    },function () {
        $('.userInfoList').hide();

    });



});




//侧边栏到发帖

$("#rightSendPost").click(function () {



    var groupId=$(this).data('groupId');
    var groupName=$(this).data('groupName');
    //头部信息
    if(islogin()){
        window.location.href='userSendPost.html?groupId='+groupId+'&groupName='+groupName;
    }else {
        $('.loginMode').show()
    }

});


//侧边栏 最新贷款，热门帖子，热门帖子，热门社区


function sidebarfn(type,eml,sidebarType) {

//    sidebarType预留侧边栏类型字段，用于区分不同侧边栏内容

//侧边栏帖子
if(type==='sidebarPost'){

    myAjaxFunc({
        url: community + "getPagePost",
        type: 'post',
        dataType: 'json',
        data: {groupId: '1000',listCurrentPage:'1'},
        mySuccess: function (data) {

            let content = data.data.pageDate.list
                , hotPost = '';


            for (let i = 0, ig = 5; i < ig; i++) {


                // 现在老版本读取图片，imgUrls的第一张
                // 新版本后应该读取封面图片，就无需用到此处
                let imgUrl=content[i].imgUrls;
                let imgList=[];

                if (notNull(imgUrl)) {
                    imgList = imgUrl.split(',');
                }
                //

                var postItemTexth4=html_encode(content[i].textContentShort);

                hotPost+='' +
                    '            <a class="postItem" href="groupPostDetail.html?id='+content[i].id+'" target="_blank">' +
                    '              <div class="imgbox"><img src="'+geturlimg+imgList[0]+'"></div>' +
                    '                <div class="postItemText">' +
                    '                    <h4>'+postItemTexth4+'</h4>' +
                    '                    <div class="thumbsUpAndPageView">' +
                    '                        <span class="thumbsUp">'+content[i].thumbUp+'</span>' +
                    '                        <span class="pageView">'+content[i].commentCount+'</span>' +   //没有浏览记录字段，先用评论字段代替
                    '                    </div>' +
                    '                </div>' +
                    '            </a>'


            }

            $(eml).empty().append(hotPost);



        }
    });

}

//侧边栏产品
if(type==='sidebarProduct'){

    myAjaxFunc({
        url:geturl+"getPageDate" ,
        type:'get',
        dataType:'json',
        data:{
            regionCode:'',
            limitHigh:'',
            limitLow:'',
            propertyName:'',
            sortName:'',
            listCurrentPage:'',

        },  mySuccess:function (data) {

            let  content=data.data.pageDate.list
                ,loansMap='';

            //返回的数据加载到页面
            for(var i=0,ig=6;i<ig;i++){

                var ilist=content[i].tagList,
                    icontent='',
                    markshow='';
                for(var j=0,jg=ilist.length;j<jg;j++){
                    icontent +='<span>'+ilist[j]+'</span>'
                }


                let marks = content[i].mark,

                    a = content[i].loanRate,        //利率
                    b = content[i].loanRateUnit,    //利率单位
                    c = content[i].loanLimitLow,    //低额度
                    d = content[i].loanLimitHigh,   //高额度
                    e = content[i].loanSpeed,       //放款速度
                    f = content[i].loanSpeedUnit;   //放款单位

                if(marks=='hot'){
                    markshow='hotBg'
                }
                if (marks=='new'){
                    markshow='newBg'
                }



                loansMap+=
                    '                          <div  class="loansItem" data-id="">' +
                    '                               <img  class="loansLogo" src="'+ geturlimg+content[i].logoUrl+'">' +
                    '                                 <div class="loanInfo">'+
                    '                                       <div class="loanInfoLeft">'+
                    '                                           <h3>'+content[i].name+'</h3>' +
                    '                                           <p>利息：<i>'+a+'%/'+b+'</i></p>' +
                    '                                           <p>额度：<i>'+c+'-'+d+'元</i></p>' +
                    '                                       </div>' +
                    '                                       <div class="loanInfoRight">' +
                    '                                          <a href="loansDetail.html?id='+content[i].id+'" target="_blank">详情</a>' +
                    '                                       </div>' +
                    '                                   </div>' +
                    '                               </div>'




            }


            $(eml).empty().append(loansMap);

        }
    });
}


    
}




//立即申请贷款统计
function upproductApply(applyUrl) {
    var fromUrl=navigator.userAgent,
        a=fromUrl.indexOf('('),
        b=fromUrl.indexOf(')'),
        d=fromUrl.slice(a,b+1),
        id=sessionStorage.getItem('productId'),
        phone= getUserInfo().phone;


    myAjaxFunc({
        url :geturl+'productApply',
        data:{id:id,phone:phone,platform:"pc/type:"+d},
        type:'post',
        mySuccess:function(data) {
            if(notNull(applyUrl)){
                switchLocation(applyUrl)
            }
       }
    })
}









/******************************************************点赞事件处理***********************************************/

var prisession = sessionStorage.getItem('pri');//获取点赞的帖子ID的集合
var pri = [];                  //点赞数据                //点赞数据
var praisebody = $('body');//事件绑定对象

//获取页面点赞帖子的id
if (notNull(prisession)) {
    pri = prisession.split(',');
}

function showPri() {
    for (var i = 0, plg = pri.length; i < plg; i++) {
        var className = "." + pri[i];
        $(className).addClass('praiseType')
    }

}

//存储点赞Id
function addPri(priid) {
    pri.push(priid);
    sessionStorage.setItem('pri', pri)
}

//删除点赞id
function removePri(priid) {
    var idIndex = pri.indexOf(priid);

    if (idIndex == '-1') {
    } else {
        pri.splice(idIndex, 1);
        sessionStorage.setItem('pri', pri)
    }

};


praisebody.on('click', '.praise', function () {

    var this_=$(this);

    var type = this_.hasClass("praiseType");

    if (type) {

        if (this_.html() > 0) {
            this_.removeClass('praiseType');
            this_.html(Number(this_.html()) - 1);
            var priid = this_.data('postid');
            myAjaxFunc({
                url: community + 'thumbDownPost',
                data: {id: priid}
            })
            removePri(priid)
        }

    } else {

        this_.addClass('praiseType');
        this_.html(Number(this_.html()) + 1);
        var priid = $(this).data('postid');

        addPri(priid); //存储点赞id

        myAjaxFunc({
            url: community + 'thumbUpPost',
            data: {id: priid}
        })
    }

});



$('.authorInfo').hover(function () {
    if(getUserInfo().roles==='管理员'){
        $('.adminDelAll').show()
        $('.adminDelThis').show()

    }
},function () {
    if(getUserInfo().roles==='管理员'){
        $('.adminDelAll').hide()
        $('.adminDelThis').hide()

    }
});





